package com.srlg.common.req;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @desc:
 * @author: srlg li
 * @date: 2023/11/27 22:41
 */
@Data
public class R<T> {

  private Integer code;
  private String message;
  private T data;

  public R() {
  }

  public R(Integer code, String message, T data) {
    this.code = code;
    this.message = message;
    this.data = data;
  }

  public R(Integer code, String message) {
    this.code = code;
    this.message = message;
  }

  public static R success() {
    return new R(200, "success");
  }

  public static <T> R success(T data) {
    return new R<T>(200, "success", data);
  }

  public static <T> R success(String message, T data) {
    return new R<T>(200, message, data);
  }


  public static R fail() {
    return new R(500, "fail", null);
  }

  public static <T> R fail(T data) {
    return new R<T>(500, "fail", data);
  }

  public static <T> R fail(String message, T data) {
    return new R<T>(500, message, data);
  }
}

